﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Drawing;

namespace Line64.ImageFlow.Activities
{

    public sealed class LoadBitmapActivity : CodeActivity
    {
        
        public InArgument<string> ImagePath { get; set; }

        public OutArgument<Bitmap> LoadedBitmap { get; set; }
        
        protected override void Execute(CodeActivityContext context)
        {

            string imagePath = this.ImagePath.Get(context);

            using (Image loadedImage = Image.FromFile(imagePath))
            {

                Bitmap loadedBitmap = new Bitmap(loadedImage);

                this.LoadedBitmap.Set(context, loadedBitmap);

            }
            
        }

    }

}